package com.ld.admin.controller.system;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ld.admin.controller.AdminBasicController;
import com.ld.common.model.SysLog;
import com.ld.shieldsb.common.core.model.Result;
import com.ld.shieldsb.common.web.util.Web;
import com.ld.shieldsb.dao.model.QueryModel;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * 操作日志信息
 * 
 * @ClassName BizLogController
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2019年01月21日 17:43:56
 *
 */
@Api(tags = "操作日志信息")
@ConditionalOnProperty(prefix = "modules.sc.system", name = "bizlog.enable", havingValue = "true", matchIfMissing = true)
@Controller(value = "systemBizLogController")
@RequestMapping("${shieldsb.adminPath}/system/bizlog")
public class BizLogController extends AdminBasicController<SysLog> {

    @ApiOperation(value = "首页", notes = "")
    @RequestMapping(path = "", method = RequestMethod.GET)
    public String index() {
        return "forward:" + adminPath + "/system/bizlog/toSearch"; // 跳转搜索页面
    }

    @ApiOperation(value = "到搜索页面", notes = "")
    @RequestMapping(path = "/toSearch", method = RequestMethod.GET)
    public String toSearch() {
        return "a/system/bizlog/bizlog_search";
    }

    @ApiOperation(value = "搜索结果", notes = "")
    @RequestMapping(path = "/search", method = RequestMethod.POST)
    public String search() {
        QueryModel queryModel = basicService.getSearchQueryModel(request, new QueryModel());
        basicService.getPageBean(request, getModelClass(), queryModel);
        return "a/system/bizlog/bizlog_list";
    }

    @ApiOperation(value = "操作日志信息展示", notes = "")
    @RequestMapping(path = "/show", method = RequestMethod.GET)
    public String show() {
        long id = getLong("id");
        basicService.getOne(request, getModelClass(), id);
        return "a/system/bizlog/bizlog_show";
    }

    @ApiOperation(value = "删除操作日志信息（物理删除）", notes = "")
    @RequestMapping(path = "/del", method = RequestMethod.POST)
    // 返回json格式
    @ResponseBody
    public Object del() {
        long id = getLong("id");
        Result result = basicService.del(getModelClass(), id);
        return Web.Response.result(result);
    }

    @ApiOperation(value = "批量删除操作日志信息（物理删除）", notes = "")
    @RequestMapping(path = "/batchdel", method = RequestMethod.POST)
    // 返回json格式
    @ResponseBody
    public Object batchdel() {
        String[] idsArray = getArray("id");
        Result result = basicService.batchDel(getModelClass(), (Object[]) idsArray);
        return Web.Response.result(result);
    }

}